using MediatR;
using RBAC.ErrorCode;

namespace RBAC.Read.Api.Application.Command.ERP.SalesManagement.Billing
{
    /// <summary>
    /// 获取开票通知单详情命令
    /// </summary>
    public class GetBillingNoticeDetailCommand : IRequest<APIResult<BillingNoticeDetailDto>>
    {
        /// <summary>
        /// 单据编号
        /// </summary>
        public string BillNumber { get; set; } = string.Empty;
    }

    /// <summary>
    /// 开票通知单详情DTO
    /// </summary>
    public class BillingNoticeDetailDto
    {
        /// <summary>
        /// 开票通知单ID
        /// </summary>
        public long Id { get; set; }

        /// <summary>
        /// 单据编号
        /// </summary>
        public string? BillNumber { get; set; }

        /// <summary>
        /// 业务类型
        /// </summary>
        public string? BusinessType { get; set; }

        /// <summary>
        /// 客户名称
        /// </summary>
        public string? CustomerName { get; set; }

        /// <summary>
        /// 开户行
        /// </summary>
        public string? BankName { get; set; }

        /// <summary>
        /// 账号
        /// </summary>
        public string? AccountNumber { get; set; }

        /// <summary>
        /// 税号
        /// </summary>
        public string? TaxNumber { get; set; }

        /// <summary>
        /// 地址电话
        /// </summary>
        public string? AddressPhone { get; set; }

        /// <summary>
        /// 交付邮箱
        /// </summary>
        public string? DeliveryEmail { get; set; }

        /// <summary>
        /// 单据日期
        /// </summary>
        public DateTime? BillDate { get; set; }

        /// <summary>
        /// 操作员
        /// </summary>
        public string? Operator { get; set; }

        /// <summary>
        /// 蓝单红字
        /// </summary>
        public string? InvoiceType { get; set; }

        /// <summary>
        /// 红字原因
        /// </summary>
        public string? RedReason { get; set; }

        /// <summary>
        /// 备注信息
        /// </summary>
        public string? Remarks { get; set; }

        /// <summary>
        /// 单据状态（数字状态码：0=开立，1=审核，2=退回）
        /// </summary>
        public int Status { get; set; }

        /// <summary>
        /// 单据状态（中文状态名：开立、审核、退回）
        /// </summary>
        public string? BillStatus { get; set; }

        /// <summary>
        /// 业务状态
        /// </summary>
        public string? BusinessStatus { get; set; }

        /// <summary>
        /// 开票物料明细列表
        /// </summary>
        public List<BillingMaterialDetailDto> Items { get; set; } = new List<BillingMaterialDetailDto>();
    }

    /// <summary>
    /// 开票物料明细详情DTO
    /// </summary>
    public class BillingMaterialDetailDto
    {
        /// <summary>
        /// 明细ID
        /// </summary>
        public long Id { get; set; }

        /// <summary>
        /// 销售订单号
        /// </summary>
        public string? OrderNumber { get; set; }

        /// <summary>
        /// 物料编码
        /// </summary>
        public string? MaterialCode { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        public string? MaterialName { get; set; }

        /// <summary>
        /// 主计量单位
        /// </summary>
        public string? Unit { get; set; }

        /// <summary>
        /// 数量
        /// </summary>
        public int? Quantity { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public decimal? UnitPrice { get; set; }

        /// <summary>
        /// 金额
        /// </summary>
        public decimal? Amount { get; set; }

        /// <summary>
        /// 开票名称
        /// </summary>
        public string? InvoiceName { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remarks { get; set; }
    }
}